home *** CD-ROM | disk | FTP | other *** search
- /*----------------------------------------------------------------------------
-
- iconutil.c
-
- This reusable module contains miscellaneous utility routines for working
- with icons.
-
- Copyright © 1994-1995, Northwestern University.
-
- ----------------------------------------------------------------------------*/
-
- #include <Icons.h>
-
- #include "def.h"
- #include "iconutil.h"
-
-
-
- /*----------------------------------------------------------------------------
- TrackIconClick
-
- Track a click on an icon control.
-
- Entry: where = location of mouse down in local coords.
- iconRect = pointer to icon rectangle.
- hotRect = pointer to "hot" rectangle, or nil to use
- icon mask.
- iconID = resource ID of icon.
-
- Exit: function result = true if icon clicked.
- ----------------------------------------------------------------------------*/
-
- Boolean TrackIconClick (Point where, Rect *iconRect, Rect *hotRect,
- short iconID)
- {
- Boolean iconDrawnSelected = false;
- Boolean hot = true;
-
- if (hotRect == nil) {
- if (!PtInIconID(where, iconRect, 0, iconID)) return false;
- } else {
- if (!PtInRect(where, hotRect)) return false;
- }
- do {
- if (hot) {
- if (!iconDrawnSelected) {
- PlotIconID(iconRect, 0, ttSelected, iconID);
- iconDrawnSelected = true;
- }
- } else {
- if (iconDrawnSelected) {
- PlotIconID(iconRect, 0, ttNone, iconID);
- iconDrawnSelected = false;
- }
- }
- GetMouse(&where);
- if (hotRect == nil) {
- hot = PtInIconID(where, iconRect, 0, iconID);
- } else {
- hot = PtInRect(where, hotRect);
- }
- } while (StillDown());
- if (iconDrawnSelected) {
- PlotIconID(iconRect, 0, ttNone, iconID);
- return true;
- } else {
- return false;
- }
- }
-